<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>重新声明变量不会破坏值</title>
</head>
<body>
    <h1>JavaScript变量</h1>
    <p>如果您再次声明某个Javascript变量，那么它的值不会丢失</p>
    <p id="demo"></p>
    <script>
        var carName = "porsche";
        var carName;
        document.getElementById("demo").innerHTML = carName;
    </script>
</body>
</html>